const map = echarts.init(document.getElementById("map"));


const initMap = mapData => {
    $.getJSON('./lib/china.json', data => {
        echarts.registerMap('china', data);
        map.setOption({
            series: [{
                type: 'map',
                map: 'china',
                itemStyle: {
                    areaColor: '#1E71FF',
                    borderColor: '#1A56D6',
                    borderWidth: 1.5,
                },
                emphasis: {
                    itemStyle: {
                        areaColor: '#00C3F5',
                    },
                },
                select: {
                    label: { show: false },
                    itemStyle: {
                        areaColor: '#1E71FF',
                    },
                },
                zoom: 1.1,
                data: mapData
            }]
        })
    })
}

// 地图
$.ajax({
    type: 'post',
    url: url + '/api/data-visualization/analysis/statistic/region',
    data: {
        beginDate: beginDate,
        endDate: endDate,
        keyword: '',
    },
    success(res) {
        if (res.code == 200) {
            initMap(res.data.map(i => ({ name: i.word, value: i.number })))
        }
    },
    error(err) {
        console.log(err);
    }
})


